package org.monkey.common.gateway.config;

import com.alibaba.csp.sentinel.adapter.gateway.sc.SentinelGatewayFilter;
import lombok.extern.slf4j.Slf4j;
import org.monkey.common.gateway.handler.SentinelFallbackHandler;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
@Configuration
@Slf4j
public class GatewayConfigBean {
  @Bean
  @Order(Ordered.HIGHEST_PRECEDENCE)
  public SentinelFallbackHandler sentinelGatewayExceptionHandler() {
    return new SentinelFallbackHandler();
  }

  @Bean
  @Order(-1)
  public GlobalFilter sentinelGatewayFilter() {
    return new SentinelGatewayFilter();
  }
}
